package com.zust.data.web.controller;

import com.zust.data.domain.param.DataSaveParam;
import com.zust.data.dto.ResponseDto;
import com.zust.data.dto.SessionInfo;
import com.zust.data.entity.DlData;
import com.zust.data.serivce.DataService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author senselyan
 * @Description:
 * @date 2018/5/10 17:31
 */
@Controller
@RequestMapping("/data")
public class DataController {

    @Inject
    private DataService dataService;

    @RequestMapping("/doSave2")
    public String save2(DataSaveParam dataSaveParam, HttpServletRequest request, HttpSession session) {
        SessionInfo sessionInfo = (SessionInfo) session.getAttribute("sessionInfo");
        dataSaveParam.setUserId(sessionInfo.getId());
        ResponseDto<DlData> responseDto = dataService.save(dataSaveParam);
        return "data/" + responseDto.getData().getId() + "/info";
    }
}
